package com.hxkj.domain.enums;

import com.platform.common.domain.exception.CustomExceptionCode;

/**
 * 用户异常枚举
 * <p>
 * Created by yaosy on 2018年6月14日19:55:36
 */
public enum UniversalExceptionEnum implements CustomExceptionCode {

    UNIVERSAL_NOT_ID(600, "网站管理ID不能为空！", 900),
    UNIVERSAL_NOT_MSG(602, "站点目录不能为空！", 900),
    UNIVERSAL_VERSION_INFO_ERROR(603, "版本信息不能为空！", 900),
    UNIVERSAL_ADD_FAILED(604, "新增网站管理失败！", 900),
    UNIVERSAL_EDIT_FAILED(605, "修改网站管理失败！", 900),
    UNIVERSAL_EXISTS_WEBSITE(606, "已存在相同的网站管理名称！", 900),
    UNIVERSAL_NAME_NOT_MSG(607, "名称不能为空！", 900),
    UNIVERSAL_SITE_NOT_MSG(608, "站点id不能为空！", 900),
    ;
    private Integer code;
    private String msg;
    private Integer httpCode;

    UniversalExceptionEnum(Integer code, String msg, Integer httpCode) {
        this.code = code;
        this.msg = msg;
        this.httpCode = httpCode;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String getMsg() {
        return msg;
    }

    @Override
    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public Integer getHttpCode() {
        return httpCode;
    }

    @Override
    public void setHttpCode(Integer httpCode) {
        this.httpCode = httpCode;
    }


    public static UniversalExceptionEnum getEnumByCode(Integer code){
        for(UniversalExceptionEnum siteExceptionEnum : UniversalExceptionEnum.values()){
            if(code.equals(siteExceptionEnum.getCode())){
                return siteExceptionEnum;
            }
        }
        return null;
    }
}
